package person;
import course.Course;
import java.util.ArrayList;
import java.util.List;

public class Student extends Person {
    private List<Course> selectedCourses;

    public Student(int id, String name, String gender) {
        super(id, name, gender);
        this.selectedCourses = new ArrayList<>();
    }

    public void selectCourse(Course course) {
        selectedCourses.add(course);
        System.out.println(name + " 成功选修课程：" + course.getName());
    }

    public void dropCourse(Course course) {
        if (selectedCourses.remove(course)) {
            System.out.println(name + " 成功退课：" + course.getName());
        } else {
            System.out.println(name + " 未选修该课程，退课失败");
        }
    }

      public void printInfo() {
        super.printInfo();
        System.out.println("\n=====" + name + "的课表=====");
        for (Course course : selectedCourses) {
            System.out.println("课程编号：" + course.getId());
            System.out.println("课程名称：" + course.getName());
            System.out.println("上课地点：" + course.getLocation());
            System.out.println("上课时间：" + course.getTime());
            if (course.getTeacher() != null) {
                System.out.println("授课教师：" + course.getTeacher().getName());
            } else {
                System.out.println("授课教师：未分配");
            }
        }
        System.out.println("====================\n");
    }
}